export default {
    namespaced: true, // 设置命名空间
    state() {
        return {
            user: {
                name: '古力娜扎',
                age: 30
            }
        }
    },
    mutations: {
        addAge(state, step) {
            console.log('step', step);
            console.log(state.user.age);
            state.user.age = state.user.age + step
        }
    },
    actions: {
        AddAgeAsync({ commit }, step) {
            setTimeout(() => {
                commit('addAge', step)
            }, 2000)
        }
    },
    getters: {
        doubleAge(state) {
            // state.user.age = state.user.age * 2
            return {
                ...state.user,
                age: state.user.age * 2
            }
        }
    }
}